package sword2offer;

public class Offer004 {
    public boolean findNumberIn2DArray(int[][] matrix, int target) {
        int m=matrix.length;
        if (m==0)return false;
        int n=matrix[0].length;
        if (n==0)return false;
        int x=m-1;
        int y=0;
        while (x>=0&&y<n){
            if (matrix[x][y]==target)return true;
            if (matrix[x][y]<target)y++;
            else x--;
        }
        return false;
    }
}
